<template>
	<view class="home-info">
		<tui-card :header="{
			line: true,
			bgcolor: 'unset'
		}" :title="{
			text:item.name,
			size:32
		}"  v-for="(item, index) in dataList" :key="index" @click="info(item)">
			<template v-slot:body>
				<tui-list-cell>
					<view class="card-label">
						<text>身</text><text>份：</text>
					</view>
					<view class="card-text">
						业主
					</view>
				</tui-list-cell>
				<tui-list-cell>
					<view class="card-label">
						<text>身</text><text>份</text><text>证</text><text>号：</text>
					</view>
					<view class="card-text">
						{{userInfo.idCard || ''}}
					</view>
				</tui-list-cell>
			</template>
		</tui-card>
		 <view class="noData" v-if="!dataList.length">暂无数据</view>
		<view class="tui-footer">
			<tui-button class="tui-btn tui-danger tui-fillet" hover-class="tui-danger-hover" @click="info()">添加房屋</tui-button>
		</view>
	</view>
</template>

<script>
	import tuiCard from "@/components/card/card"
	import tuiListCell from "@/components/list-cell/list-cell"
	import tuiButton from "@/components/button/button"
	import utils from "@/utils/util.js"
	export default {
		components:{tuiCard, tuiListCell, tuiButton},
		data(){
			return {
				dataList:[
					// {
					// 	name:'长沙恒大华府36栋1单元19层1908',
					// 	type:'业主',
					// 	phone:'180****3385',
					// 	idCard:'430**************825'
					// }
				]
			}
		},
		computed:{
			userInfo(){
				let us = {}
				try{
					us = uni.getStorageSync(this.java110Constant.mapping.USER_INFO);
					us = this.java110Util.des.desDecrypt(us)
					us = JSON.parse(us)
				}catch(e){
					//TODO handle the exception
				}
				return us
			}
		},
		mounted() {
		   uni.showNavigationBarLoading()	
		   setTimeout(() => {
			    uni.hideNavigationBarLoading()
		   },1000)
		   this.loadOwnerHouse();
		},
		methods:{
			info(data){
				let url = '/pages/my/bindOver?'
				if(data){
					url = './infoHouse?'
				}
				// data = data?{...data, edit:true}:{edit:false};
				data = data || {};
				data = utils.param(data);
				uni.navigateTo({
					url:url+data
				})
			},
			/**
			   * 加载业主房屋信息
			   */
		    loadOwnerHouse:function(){
			  let _that = this;
			  uni.showLoading({
			  	mask: true,
			  	title: '请稍候...'
			  })
			  this.java110Context.getRooms().then(res=>{
				uni.hideLoading();
				if(res){
				 res.data.rooms = res.data.rooms.map(_item => {
					 _item.name = (_item.floorNum + "号楼" + _item.unitNum + "单元" + _item.roomNum + "室")
					 return _item
				 }) 
				  _that.dataList = res.data.rooms || [];
				}
			   })
			}
		}
	}
</script>


<style>
	.home-info{
		height: calc(100vh - 150upx - 30upx);
		overflow-y: auto;
		padding-bottom: 150upx;
		padding-top: 30upx;
		box-sizing: border-box;
		position: relative;
		background-color: rgb(247, 249, 251);
	}
	.home-info .tui-cell-class{
		background: unset !important;
		color: #666 !important;
	}
	.home-info .tui-card-header{
		background: unset !important;
		color: #666;
	} 
	.home-info .tui-card-class{
		/* background-image: linear-gradient(to bottom, #EB0909 0, #e41f19 100%);
		  background-image: -webkit-linear-gradient(top, #EB0909 0, #e41f19 100%);
		  background-image: -o-linear-gradient(top, #EB0909 0, #e41f19 100%);
		  background-image: -webkit-gradient(
		    linear,
		    left top,
		    left bottom,
		    from(#EB0909),
		    to(#e41f19)
		  ); */
	}
	.home-info .tui-footer{
		position: fixed;
		bottom: 30upx;
		left: 0;
		right: 0;
		padding: 30upx 40upx;
	}
	.home-info .card-label{
		width: 100px;
		display: flex;
		justify-content: space-between;
		text-align: justify;
	}
	.home-info .tui-cell-class{
		display: flex;
		justify-content: space-between;
	}
	.home-info .tui-card{
		margin: 30upx 32upx;
	}
</style>
